package com.charity.rest.controller.manage.system;

import com.charity.system.service.IDeptService;
import com.charity.system.vo.model.DeptModel;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户中心-部门  前端控制器
 *
 */
@RestController
@RequestMapping("/manage/system/dept")
@AllArgsConstructor
public class DeptController {

    private final IDeptService deptService;

    @PostMapping("/getTreeList")
    public List<DeptModel> getTreeList(@RequestBody DeptModel model) {
        return deptService.getTreeList(model);
    }

    @GetMapping(value = "/{id}")
    public DeptModel getDeptById(@PathVariable("id") Long id) {
        return deptService.getDeptById(id);
    }

    @PostMapping("/createDept")
    public Long createDept(@RequestBody DeptModel model) {
        return deptService.createDept(model);
    }

    @PostMapping("/updateDept")
    public void updateDept(@RequestBody DeptModel model) {
        deptService.updateDept(model);
    }

    @DeleteMapping("/{id}")
    public Integer deleteDept(@PathVariable("id") Long id) {
        return deptService.deleteDept(id);
    }
}
